package com.dubbo.mapper;

import com.dubbo.domain.RefundItem;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;
import java.util.Map;

/**
 * 退货/换货 商品选项
 * @author chenluqiang
 * @date 2018年12月15日 下午3:25:03 
 *
 */
public interface RefundItemMapper extends Mapper<RefundItem>{
	
	/**
	 * 售后商品item信息
	 * @author chenluqiang
	 * @date 2018年12月18日 上午11:36:30 
	 * @param refundId
	 * @return
	 */
	@Select("SELECT " + 
			"	sri.id AS itemId, " + 
			"	sri.goodsTitle, " + 
			"	sri.goodsCount, " + 
			"	sri.goodsPic, " + 
			"	sri.goodsPrice, " + 
			"IF ( " + 
			"	sri.categoryId = 0 " + 
			"	OR ISNULL(sri.categoryId), " + 
			"	ggs.categoryId, " + 
			"	sri.categoryId " + 
			") AS categoryId, " + 
			" " + 
			"IF ( " + 
			"	ISNULL(srd.cause), " + 
			"	'', " + 
			"	srd.cause " + 
			") AS cause " + 
			"FROM " + 
			"	s_refund_item sri " + 
			"LEFT JOIN s_refund srd ON srd.id = sri.refundId " + 
			"LEFT JOIN g_goods ggs ON ggs.id = sri.goodsId " + 
			"WHERE sri.refundId = #{refundId}")
	List<Map<String, Object>> getRefundItemByRefundId(@Param("refundId") String refundId);
}